package functii.trigonometrice;

import operatori.Cat;
import operatori.Minus;
import functii.Functie;
import functii.elementare.Putere;
import functii.elementare.Radical;

public class Arcsin extends Functie{
    public static double calcul(double aux1){
        return Math.asin(aux1);
    }

    public double calcul(){
        if(fStang == null)
            System.exit(1);
        return calcul(fStang.calcul());
    }

    public String derivare(){
        if(fStang == null)
            System.exit(1);
        return Cat.concatTermens("1.0", Radical.concatTermens(Minus.concatTermens("1.0", Putere.concatTermens("x"))));
    }

    public double calculDerivata(){
        if(fStang == null)
            System.exit(1);
        return Cat.Calcul(1.0, Radical.calcul(Minus.Calcul(1.0, Putere.calcul(x))));
    }

    public String toString(){
        if(fStang == null)
            System.exit(1);
        return concatTermeni(fStang.toString());
    }

    public static String concatTermeni(String aux1){
        String aux;
        int nrP;

        nrP = aux1.charAt(0) == '(' ? 0 : 2;

        aux = "arcsin";
        if(nrP != 0) aux += "(";
        aux += aux1;
        if(nrP != 0) aux += ")";

        return aux;
    }
}
